package com.bytedance.scenedemo;

import com.bytedance.scene.Scene;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.IntentParams;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.LayoutScatter;
import org.junit.Test;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;

public class SceneTest {

    @Test
    public void testNonNullArguments() {
        Scene scene = new Scene() {
            @Override
            public Component onCreateView(LayoutScatter scatter, ComponentContainer container, Intent intent) {
                return new Component(requireSceneContext());
            }
        };
        IntentParams params = new IntentParams();
        scene.setArguments(params);
        assertSame(params, scene.requireArguments());
        assertSame(params, scene.getArguments());
    }

    @Test
    public void testRequireViewAfterOnCreateView() {
        Scene scene = new Scene() {

            @Override
            public Component onCreateView(LayoutScatter scatter, ComponentContainer container, Intent intent) {
                return new Component(requireSceneContext());
            }
        };
        assertSame(null,scene.getView());
        assertNotNull(scene);
    }
}
